package com.helen.adapter;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.helen.entity.QuestionEntity;
import com.helen.entity.TeamEntity;
import com.helen.shopping.R;
import com.helen.utils.MyLog;

import java.util.List;


/**
 * Created by yang on 2018/5/2.
 */

public class QuestionListAdapter extends BaseQuickAdapter<QuestionEntity, BaseViewHolder> {

    public QuestionListAdapter(List<QuestionEntity> data) {
        super(R.layout.item_question_list, data);

    }


    @Override
    protected void convert(final BaseViewHolder helper, final QuestionEntity item) {
        try {
            RelativeLayout relQuestion = (RelativeLayout) helper.getView(R.id.rel_question);
            TextView tvQuestion = (TextView) helper.getView(R.id.tv_question);
            final LinearLayout llAnswer = (LinearLayout) helper.getView(R.id.ll_answer);
            TextView tvAnswer = (TextView) helper.getView(R.id.tv_answer);
            tvQuestion.setText(item.getQuestion());
            tvAnswer.setText(item.getAnswer());
            relQuestion.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if(llAnswer.getVisibility() == View.GONE){
                        llAnswer.setVisibility(View.VISIBLE);
                    }else {
                        llAnswer.setVisibility(View.GONE);
                    }
                }
            });

        } catch (Exception e) {
            MyLog.e("yang", "设置团队列表异常" + e.toString());
        }


    }


}
